package root.service;

import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;

/**
 * @author 吕梁山
 * @date 2018/9/26
 */
public class LoginService {

    public Record getLoginUser(String username){
        String sql = "select * from t_manager_user where username = " + username + " and status = 0";
        return Db.findFirst(sql);
    }

    public Record checkLoginInfo(String username, String password){
        String sql = "select * from t_manager_user where username = " + username + " and password = '" + password + "'";
        return Db.findFirst(sql);
    }

    /**
     * 更新用户最后登录时间
     */
    public void updateUserLoginDate(String id) {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("update t_manager_user set login_date = now() where id = " + id);
        Db.update(stringBuilder.toString());
    }
}
